#include <stdio.h>

int main(int argc, char *argv[])
{
	int h1, m1, s1, h2, m2, s2, tmp1, tmp2, re;
	scanf("%d:%d:%d", &h1, &m1, &s1);
	scanf("%d:%d:%d", &h2, &m2, &s2);

	tmp1 = h1 * 3600 + m1 * 60 + s1;
	tmp2 = h2 * 3600 + m2 * 60 + s2;

	re = abs(tmp1 - tmp2);
	printf("%d\n", re);

	return 0;
}
